<?php
class Server {
  public static function delete_obj($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    $opts = new stdClass();
    $opts->cd = 'intake_id = :v1';
    $opts->cdv = array(':v1' => $req->id);
    $orm->delete_by_opts('pb_colg_class', $opts);
    
    $orm->delete('pb_colg_intake', $req);
    
    if (isset($req->__pg)) {
      $opts = new stdClass();
      $opts->cd = 't.type = :v1';
      $opts->cdv = array(':v1' => PT_DIPLOMA);
      $res = $orm->get('pb_colg_intake', 't.start', 'ASC', $req->__pg, SIZE, $opts);
      echo json_encode($res);
    }
  }
  
  public static function get_objs($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    $opts = new stdClass();
    $opts->cd = 't.type = :v1';
    $opts->cdv = array(':v1' => PT_DIPLOMA);
    $res = $orm->get('pb_colg_intake', $req->o, $req->q, $req->pg, SIZE, $opts);
    echo json_encode($res);
  }
}
?>